/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.appleboxstore.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.swing.JOptionPane;

/**
 *
 * @author alexander
 */
public class SystemUtils {

    public static synchronized String md5(String senha) {

        String sen = "";
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        BigInteger hash = new BigInteger(1, md.digest(senha.getBytes()));
        sen = hash.toString(16);
        return sen;
    }

    public static String generatePassword() {
        return md5(Long.toString(System.currentTimeMillis(), 36)).substring(0, 8);
    }

    public static void notImplemented() {
        JOptionPane.showMessageDialog(null, "Funcionalidade não implementada");
    }

    public static void showInfo(String message, String title) {
        JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
    }

    public static void showErro(String message, String title) {
        JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
    }
}
